home *** CD-ROM | disk | FTP | other *** search
/ SVM Mac 58 / CD-ROM N°58.iso / navigateurs / Netscape Folder / chrome / wallet / content / default / WalletPreview.js < prev    next >
Encoding:
JavaScript  |  2000-04-19  |  4.7 KB  |  138 lines  |  [TEXT/MOSS]

  1.     /* for localization */
  2.     var Bundle = srGetStrBundle("chrome://wallet/locale/WalletPreview.properties");
  3.     var heading = Bundle.GetStringFromName("heading");
  4.     var bypass = Bundle.GetStringFromName("bypass");
  5.     var okCmdLabel = Bundle.GetStringFromName("okCmdLabel");
  6.     var cancelCmdLabel = Bundle.GetStringFromName("cancelCmdLabel");
  7.  
  8.     /* for xpconnect */
  9.     var walletpreview =
  10.       Components.classes
  11.         ["component://netscape/walletpreview/walletpreview-world"].createInstance();
  12.     walletpreview = walletpreview.QueryInterface(Components.interfaces.nsIWalletPreview);
  13.  
  14.     function DoGetPrefillList()
  15.     {
  16.       return walletpreview.GetPrefillValue();
  17.     }
  18.  
  19.     function DoSave(value)
  20.     {
  21.       walletpreview.SetValue(value, window);
  22.     }
  23.     /* end of xpconnect stuff */
  24.  
  25.     index_frame = 0;
  26.     title_frame = 1;
  27.     list_frame = 2;
  28.     button_frame = 3;
  29.     var prefillList = [];
  30.  
  31.     function loadFillins(){
  32.       top.frames[title_frame].document.open();
  33.       top.frames[title_frame].document.write
  34.         (" " + heading);
  35.       top.frames[title_frame].document.close();
  36.  
  37.       top.frames[list_frame].document.open();
  38.       top.frames[list_frame].document.write(
  39.         "<form name='fSelectFillin'>" +
  40.           "<br/>" +
  41.           "<table border='0'>" +
  42.             "<tr>" +
  43.               "<td>" +
  44.                 "<br/>" 
  45.       )
  46.       var count;
  47.       for (i=1; !(i>=prefillList.length-2); i+=3) {
  48.         if(prefillList[i] != 0) {
  49.           count = prefillList[i];
  50.           top.frames[list_frame].document.write(
  51.                 "<tr>" +
  52.                   "<td>" + prefillList[i+1] + ":  </td>" +
  53.                   "<td>" +
  54.                     "<select>" 
  55.           )
  56.           count--;
  57.         }
  58.         top.frames[list_frame].document.write(
  59.                       "<option VALUE='"+prefillList[i+1]+"'>" +
  60.                         prefillList[i+2] +
  61.                       "</option>" 
  62.         )
  63.         if(count == 0) {
  64.           top.frames[list_frame].document.write(
  65.                       "<option VALUE='"+prefillList[i+1]+"'><do not prefill></option>" +
  66.                     "</select><br/>" +
  67.                   "</td>" +
  68.                 "</tr>" 
  69.           )
  70.         }
  71.       }
  72.       top.frames[list_frame].document.write(
  73.               "</td>" +
  74.             "</tr>" +
  75.           "</table>" +
  76.         "</form>"
  77.       );
  78.       top.frames[list_frame].document.close();
  79.     };
  80.  
  81.     function loadButtons(){
  82.       top.frames[button_frame].document.open();
  83.       top.frames[button_frame].document.write(
  84.         "<form name=buttons>" +
  85.           "<br/>" +
  86.           "<input type='checkbox' name='skip'> " +
  87.             bypass +
  88.           "</input> " +
  89.           "<br/>" +
  90.           "<br/>" +
  91.           "<div align='center'>" +
  92.             "<button onclick='parent.Save();'>" + okCmdLabel + "</button>" +
  93.             "   " +
  94.             "<button onclick='parent.Cancel();'>" + cancelCmdLabel + "</button>" +
  95.           "</div>" +
  96.           "<input type='hidden' name='fillins' value=' ' size='-1'>" +
  97.           "<input type='hidden' name='list' value=' ' size='-1'>" +
  98.           "<input type='hidden' name='url' value=' ' size='-1'>" +
  99.         "</form>"
  100.       );
  101.       top.frames[button_frame].document.close();
  102.     }
  103.  
  104.     function loadFrames(){
  105.       list = DoGetPrefillList();
  106.       BREAK = list[0];
  107.       prefillList = list.split(BREAK);
  108.       loadFillins();
  109.       loadButtons();
  110.     }
  111.  
  112.     function Save(){
  113.       selname = top.frames[list_frame].document.fSelectFillin;
  114.       var list = top.frames[button_frame].document.buttons.list;
  115.       var url = top.frames[button_frame].document.buttons.url;
  116.       var skip = top.frames[button_frame].document.buttons.skip;
  117.       list.value = prefillList[prefillList.length-2];
  118.       url.value = prefillList[prefillList.length-1];
  119.       var fillins = top.frames[button_frame].document.buttons.fillins;
  120.       fillins.value = "";
  121.       for (i=0; !(i>=selname.length); i++) {
  122.         fillins.value = fillins.value +
  123.           selname.elements[i].options[selname.elements[i].selectedIndex].value + "#*%$" +
  124.           selname.elements[i].options[selname.elements[i].selectedIndex].text + "#*%$";
  125.       }
  126.       var result = "|list|"+list.value+"|fillins|"+fillins.value;
  127.       result += "|url|"+url.value+"|skip|"+skip.checked+"|";
  128.       DoSave(result);
  129.     }
  130.  
  131.     function Cancel(){
  132.       selname = top.frames[list_frame].document.fSelectFillin;
  133.       var list = top.frames[button_frame].document.buttons.list;
  134.       list.value = prefillList[prefillList.length-2];
  135.       var result = "|list|"+list.value+"|fillins||url||skip|false|";
  136.       DoSave(result);
  137.     }
  138.